<?php

use yii\helpers\Html;
use yii\grid\GridView;
use common\components\grid\GridView2015;
use common\models\SysUsers;
/* @var $this yii\web\View */
/* @var $searchModel common\models\searchs\SearchSysUsers */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '用户审核';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="sys-users-index">

    <h1><?= Html::encode($this->title) ?></h1>

<!--    <p>
        < Html::a('Create Sys Users', ['create'], ['class' => 'btn btn-success']) ?>
    </p>-->

    <?= common\components\grid\ GridView2015::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'enableButton'=>FALSE,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            'id',
            'phone',
            'company_name',
//            [
//                'class' => 'common\components\grid\DataColumn2015',
//                'attribute' => 'company_name',
//                'value' => function($searchModel) {
//                    return SysUsers::ParentName($searchModel->parent_id);
//                },
//            ],
//            [
//                'class' => 'common\components\grid\DataColumn2015',
//                'attribute' => 'parent_id',
//                'label'=>'归属公司',
//                'value' => function($searchModel) {
//                    return parent_id;
//                },
//            ],
             
             'truename',
             'company_addr',
             
            
                        
            [
                'class' => 'common\components\grid\DataColumn2015',
                'attribute' => 'role',
                 'label'=>'审核',
                'format'=>'raw',
                'filter' => ['0'=>'个人用户','1'=>'业务','2'=>'财务','3'=>'未认证','4'=>'已认证'],
                'value' => function($searchModel) {
                 if($searchModel->role == 4){
                        return  Html::a('已认证');
                    }else if($searchModel->role == 3){
                         return Html::a('' ,['getbytype','id'=>$searchModel->id,'role'=>$searchModel->role], ['class' => 'glyphicon glyphicon-remove text-danger is_self']);
                    }else if($searchModel->role == 2){
                        return Html::a('财务');
                    }else if($searchModel->role == 1){
                        return Html::a('业务');
                    }else{
                        return Html::a('个人用户');
                    }
                },
            ],
            [
                'class' => 'common\components\grid\DataColumn2015',
                'attribute' => 'type',
                 'label'=>'驳回',
                'format'=>'raw',
                 'filter' => ['1'=>'已申请','2'=>'申请驳回','3'=>'申请通过'],
                'value' => function($searchModel) {
                 if($searchModel->type == ''){
                        return  Html::a('未申请');
                    }else if($searchModel->type == 1){
                         return Html::a('驳回申请',['audit','id'=>$searchModel->id,'type'=>$searchModel->type]);
                    }else if($searchModel->type == 2){
                        return Html::a('申请已驳回');
                    }else if($searchModel->type == 3){
                         return Html::a('申请通过');
                    }
                },
            ],
                        
             [
                'class' => 'common\components\grid\DataColumn2015',
                'attribute' => 'status',
                 'label'=>'状态',
                'format'=>'raw',
                 'filter' => ['2'=>'停用','1'=>'正常'],
                'value' => function($searchModel) {
                 if($searchModel->status == 1){
                        return  Html::a('' ,['getusertype','id'=>$searchModel->id,'status'=>$searchModel->status], ['class' => 'glyphicon glyphicon-ok text-success is_self']);
                    }else{
                         return Html::a('' ,['getusertype','id'=>$searchModel->id,'status'=>$searchModel->status], ['class' => 'glyphicon glyphicon-remove text-danger is_self']);
                    }
                },
            ],
            'last_login_time:datetime',

            [
            'class' => 'common\components\grid\ActionColumn2015',
            'template' => '{view}',
               
            ],
        ],
    ]); ?>

</div>
